package com.lm.categories;

import java.util.ArrayList;
import java.util.List;

/**
 * The {@link XmlCategories} class contains all the Categories available for the menu.
 * The {@link XmlCategories} are based on the <b>categories.xml</b> file.
 * This class implements the design pattern Singleton. The methode getInstance() must be used.
 */
public class XmlCategories {
	private static XmlCategories categories = null;
	private List<XmlCategory> listCategories = new ArrayList<XmlCategory>();
	
	private XmlCategories(){}
	
	/**
	 * Get the unique instance of the class {@link XmlCategories}.
	 * @return The unique instance of {@link XmlCategories}.
	 */
	public static XmlCategories getInstance() {
		if (categories == null) {
			categories = new XmlCategories();
		}
		return categories;
	}

	/**
	 * Get the attribute <b>listCategories</b>.
	 * @return The attribute <b>listCategories</b>
	 */
	public List<XmlCategory> getListCategories() {
		return this.listCategories;
	}
	
	/**
	 * Add one {@link XmlCategory} is the {@link List} <b>listCategories</b>.
	 * @param XmlCategory
	 * 	The {@link XmlCategory} to add in <b>listCategories</b>.
	 */
	public void addCategory(XmlCategory XmlCategory) {
		this.listCategories.add(XmlCategory);
	}
}
